<template>
    <el-card shadow="never" style="max-height: 700px; overflow: auto">
        <el-form ref="form" :model="form" :rules="rules" label-width="90px" :disabled="disabled" @submit.native.prevent>
            <el-form-item label="id:" prop="id" v-show="false">
                <el-input v-model="form.id" disabled />
            </el-form-item>
            <el-form-item label="编号:" prop="brand" v-if="disabled">
                <el-input v-model="form.brand" placeholder="请输入编号" clearable />
            </el-form-item>
            <el-form-item v-if="disabled">
                <el-table
                    :data="tf_lists"
                    style="width: 100%">
                  
                    <!-- <el-table-column
                        prop="brand"
                        label="编号"
                        width="">
                    </el-table-column> -->
                    <!-- <el-table-column
                        prop="cd_time"
                        label="时间">
                    </el-table-column> -->
                    <el-table-column
                        prop="roi"
                        label="ROI">
                    </el-table-column>
                    <el-table-column
                        prop="tf_admin"
                        label="投放人员">
                    </el-table-column>
                    <el-table-column
                        prop="tf_status"
                        label="投放状态">
                    </el-table-column>
                    <!-- <el-table-column
                        prop="apply_status"
                        label="审核状态">
                    </el-table-column> -->
                    <el-table-column
                        prop="check_time"
                        label="投放开始时间"
                        width="">
                    </el-table-column>
                </el-table>
            </el-form-item>
            

            <!-- <el-button type="primary" @click="submitForm">确认 </el-button> -->
                
            <!-- <el-form-item>
                <el-button type="primary" @click="submitForm">确认 </el-button>
                <el-button type="warning" @click="cancel">取消 </el-button>
            </el-form-item> -->
        </el-form>
    </el-card>
</template>

<script>
export default {
    name: 'EditForm',
    props: {
        findFormData: {
            type: Object,
            default: {},
        },
        editFormParams: {
            type: Object,
            default: {},
        },
        // 表单是否禁用
        disabled: {
            type: Boolean,
            default: false,
        },
    },
    created() {
        this.tf_list();
    },
    data() {
        return {
            // 编辑表单验证规则
            rules: {},
            form: {},
            tf_lists: [],
            images: [
                
            ],
            productvariants: [],
            attributes: [
                
            ],
            classification:[
                {
                    'title':'Bars',
                },{
                    'title':'内裤',
                },
            ],
            tags: [],
            inputVisible: false,
            inputValue: '',
        }
    },
    watch: {
        findFormData: {
            handler(nval) {
                if (JSON.stringify(nval) != '{}') {
                    this.$nextTick(() => {
                        this.form = nval
                        this.tags = nval.tags
                        this.images = nval.images2
                        this.attributes = nval.options
                        this.productvariants = nval.productvariants
                        this.tf_list();
                    })
                }
            },
            immediate: true,
            deep: false,
        },
    },
    methods: {
        // 取消按钮
        cancel() {
            this.$emit('editFormCancel')
        },

        submitForm() {
            this.$refs['form'].validate((valid, obj) => {
                if (valid) {
                    this.$emit('submitForm', this.form)
                }
            })
        },

        // 表单重置
        reset() {
            this.resetForm('form')
        },

        
        showInput() {
        this.inputVisible = true;
        this.$nextTick(_ => {
            this.$refs.saveTagInput.$refs.input.focus();
            });
        },
        handleInputConfirm() {
        let inputValue = this.inputValue;
        if (inputValue) {
            if(this.tags == ''){
                this.tags = []
            }
            this.tags.push(inputValue);
            this.form.tags = this.tags
            }
            this.inputVisible = false;
            this.inputValue = '';
        },
        handleClose(tag) {
            this.tags.splice(this.tags.indexOf(tag), 1);
            this.form.tags = this.tags
        },
        change(val) {
            this.color_change = val;
        },
        async tf_list() {
            if(this.form.brand == undefined){

            }else{
                let response = await this.request.post('/admin/product/tf_list', { 
                    brand : this.form.brand,
                })
                if(response.code == 1){
                    this.tf_lists = response.data;
                }
            }
            
        }
    },
}
</script>
<style>
    .image {
        width: 100%;
        display: block;
        /* height: 100%; */
    }
    .el-tag + .el-tag {
        margin-left: 10px;
    }
    .button-new-tag {
        margin-left: 10px;
        height: 32px;
        line-height: 30px;
        padding-top: 0;
        padding-bottom: 0;
    }
    .input-new-tag {
        width: 90px;
        margin-left: 10px;
        vertical-align: bottom;
    }
    h3{
        margin:5px 0;
        padding:5px 0;
    }
</style>